#define PIN_MIC    0

void setup() {
 pinMode(PIN_MIC, INPUT); 
 Serial.begin(9600);
}

void loop() {
  int micLevel = analogRead(PIN_MIC);
  int newVal = map(micLevel, 0, 1023, 0, 40);
  for (; newVal >= 0; --newVal)
    Serial.print("#");
  Serial.println();
  delay(100);
}
